#pragma once

#include "Object.h"

namespace BaseType
{

class BASE_TYPE_API DateTime
{
public:

    DateTime();
    DateTime(const DateTime& dt);
    DateTime(int dt);
    DateTime(int iYear, int iMonth, int iDay);
    DateTime(const String& strDate);

    static DateTime Today();

    bool IsValid() const;

    void Reset();
    void ResetToday();

    uint8_t GetWeekDay() const;
    uint16_t GetYearDay() const;

    uint16_t GetYear() const;
    uint8_t GetMonth() const;
    uint8_t GetDay() const;

    uint8_t GetHour() const;
    uint8_t GetMinute() const;
    uint8_t GetSecond() const;

    void SetYear(uint16_t val);
    void SetMonth(uint8_t val);
    void SetDayOfMonth(uint8_t val);

    bool IsQuarterEnd();
    bool IsMonthEnd();
    bool IsLeapYear() const;

    int GetMonthEndDay() const;
    int GetDayCount() const;

    void SetDate(int iYear, int iMonth, int iDay);
    void SetDate(int iDayCount);
    void SetDate(const DateTime& dt);
    void SetDate(const String& strDate);

    void SetTime(uint8_t h, uint8_t m, uint8_t s);

    String ToString();
    String ToTime();
    String ToLongDate();

    void SetMonthBegin();
    void SetMonthEnd();

    void SetQuarterBegin();
    void SetQuarterEnd();
    void SetPrevQuarter();
    void SetNextQuarter();

    void SetPrevSemiYear();
    void SetNextSemiYear();

    void SetYearBegin();
    void SetYearEnd();

    void AddDays(int iCount);
    void AddMonths(int iCount);
    void AddQuarters(int iCount);

    DateTime& operator+=(int iDayCount);
    DateTime& operator-=(int iDayCount);
    DateTime& operator=(const DateTime& dt);
    DateTime& operator=(int iDayCount);

    bool Equals(Object* Other);
    int Equal(const DateTime& dt);

private:

    uint16_t _iYear;
    uint8_t _iMonth;
    uint8_t _iDay;

    uint8_t _iHour;
    uint8_t _iMin;
    uint8_t _iSec;
};

class BASE_TYPE_API ODateTime : public Object
{
public:

    RTTIOfClass(ODateTime)

    ODateTime();
    ODateTime(const DateTime& dt);

    DateTime& GetDateTime();
    void SetDateTime(const DateTime& dt);

    bool Equals(Object* Other);

private:

    DateTime _dateTime;
};

}
